package com.example.hotelmanager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.hotelmanager.entity.CheckIn;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author :chenjie
 * @date :Created 2022/11/27 22:41
 */
@Mapper
public interface CheckInMapper extends BaseMapper<CheckIn> {
    @Select("select * from check_in where state = 1 and ((from_time > #{fromTime} and to_time < #{toTime}) or (from_time >  #{fromTime} and from_time < #{toTime})or (to_time > #{fromTime} and to_time < #{toTime})or (from_time < #{fromTime} and to_time> #{toTime}) )")
    List<CheckIn> getValidCheckIns(Timestamp fromTime, Timestamp toTime);
    @Select("select * from check_in where state = 1 and ((from_time > #{fromTimeT} and to_time < #{toTimeT}) or (from_time >  #{fromTimeT} and from_time < #{toTimeT})or (to_time > #{fromTimeT} and to_time < #{toTimeT})or (from_time < #{fromTimeT} and to_time> #{toTimeT}) );")
    List<CheckIn> getValidCheckIns1(Timestamp fromTimeT, Timestamp toTimeT);
}
